<template>
	<view class="wrap">
		<view class="cflex mt20 aic">
			<image  :src="domain + '/static/postTypeHeader.png'" mode="aspectFit"></image>
			<text class="f16 fbold">请选择要发布的内容类型</text>
			<view class="dflex mt12">
				<text class="f14 ca3a3a3">不会选择？查看不同类型发布教程</text>
				<u-icon name="arrow-right" color="#333" size="14"></u-icon>
			</view>
		</view>
		
		<view class="dflex bg_fff p12 radius10 mt20 aic" @click="postTopic">
			<u-icon name="plus-circle-fill" color="#FEC538" size="50"></u-icon>
			<view class="cflex fg1 ml5">
				<text class="f16 fbold">发布精彩图文瞬间</text>
				<text class="f14 ca3a3a3 mt5">吸粉、求助、挂载团购赚分佣</text>
			</view>
			<u-icon name="arrow-right" color="#333" size="16"></u-icon>
		</view>
		
		<view class="dflex bg_fff p12 radius10 mt20 aic" @click="postGroupPurchase">
			<u-icon name="plus-circle-fill" color="#05C160" size="50"></u-icon>
			<view class="cflex fg1 ml5">
				<text class="f16 fbold">商户发起同城美食、娱乐团购</text>
				<text class="f14 ca3a3a3 mt5">用户线上购买线下消费</text>
			</view>
			<u-icon name="arrow-right" color="#333" size="16"></u-icon>
		</view>
		
		<!-- <view class="dflex bg_fff p12 radius10 mt20 aic">
			<u-icon name="plus-circle-fill" color="#FF6620" size="50"></u-icon>
			<view class="cflex fg1 ml5">
				<text class="f16 fbold">发布实物类团购</text>
				<text class="f14 ca3a3a3 mt5">需邮寄或同城派送的商品</text>
			</view>
			<u-icon name="arrow-right" color="#333" size="16"></u-icon>
		</view>	 -->
		
		<view class="dflex mt20 jcc">
			<text class="f14">请勿发布违规、违法内容</text>
		</view>	
		
		<!-- <view class="dflex mt20 jcc">
			<text class="f14">《{{ appNameLite }}禁发商品及信息管理规范》</text>
		</view>	 -->
		
		<view class="bottom_menu">
			<bottomMenu></bottomMenu>
		</view>
		
		<userCheck ref="userCheck" @userCheckStatus="userCheckStatus"></userCheck>
		
	</view>
</template>

<script>
	
	const appNameLite = getApp().globalData.appNameLite;
	
	export default {
		data() {
			return {
				domain : uni.getStorageSync('domain'),
				appNameLite : appNameLite,
				afterLogin : '',
				identStatus : ''
			}
		},
		onLoad() {			
			//获取code一键登录
			this.$refs.userCheck.getWxCode()
		},
		methods: {
			postTopic() {
				//先判断登录，如果没有登录，赋值‘goodsfav’
				//当userCheckStatus收到子组件返回的数据时
				//根据不同的赋值继续操作
				this.$refs.userCheck.user_check()
				this.afterLogin = 'gotoTopic'
			},		
			postGroupPurchase() {
				//先判断登录，如果没有登录，赋值‘goodsfav’
				//当userCheckStatus收到子组件返回的数据时
				//根据不同的赋值继续操作
				this.$refs.userCheck.user_check()
				this.afterLogin = 'gotoGroupPurchase'
			},		
			userCheckStatus(res) {
				//发布瞬间
				if(this.afterLogin == 'gotoTopic') {
					if(res != 'already') {
						uni.setStorageSync("access_member_info", res.data)
					}
					uni.navigateTo({
						url:"/pages/member/postNew"
					})
				}
				//发布团购
				if(this.afterLogin == 'gotoGroupPurchase') {
					if(res != 'already') {
						uni.setStorageSync("access_member_info", res.data)
					}
					//判断是否认证					
					uni.request({
						url: uni.getStorageSync('domain') + '/api/v1/users/ident/check',
						method: 'GET',
						header: {
							'Authorization': 'Bearer ' + uni.getStorageSync('access_member_info').access_token,
						},
						success: (res) => {
							if (res.statusCode == 401) {
								uni.navigateTo({
									url: '/pages/member/member'
								})
							} else {
								this.identStatus = res.data.identStatus
								this.identType = res.data.identType
								if (this.identStatus == 0) {
									uni.showModal({
										title:'认证提示',
										content:'发布团购内容需先通过实名认证，是否需要认证？',
										success: function (res) {
											if (res.confirm) {
												uni.navigateTo({
													url: '/packageShop/ident/ident'
												})
											}
										}
									})
								}
								//认证成功，直接进入商户中心
								if (this.identStatus == 10) {
									console.log('123')
									uni.navigateTo({
										url: '/packageShop/merchant/goodsList'
									})
								}
								//认证中或失败，进入认证首页，查看原因
								if (this.identStatus == 15 || this.identStatus == 5) {
									uni.navigateTo({
										url: '/packageShop/ident/ident'
									})
								}
							}
							uni.hideLoading();
						},
						fail: (res) => {}
					})
				}
			},
		}
	}
</script>

<style>
	page {
		background-color: #F6F7FB;
	}
</style>
